using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Doctors_WebForum
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string module = Request["module"];
            Control c = null;
            if (module != null)
            {
                //Category modules
                if (module.Equals("category"))
                {
                    c = Page.LoadControl("UIControl/Contents/Category.ascx");
                }
                //Account modules
                if (module.Equals("account"))
                {
                    if (Request["action"].ToString().Equals("login"))
                        c = Page.LoadControl("UIControl/Accounts/Login.ascx");
                    else if (Request["action"].ToString().Equals("register"))
                        c = Page.LoadControl("UIControl/Accounts/Account.ascx");
                    else if (Request["action"].ToString().Equals("profile") && Request["action"] != null)
                        c = Page.LoadControl("UIControl/Accounts/Profile.ascx");
                    else
                        c = Page.LoadControl("UIControl/Accounts/Account.ascx");
                }
                //Post module
                if (module.Equals("post"))
                {
                    if (Request["cateid"] != null)
                        c = Page.LoadControl("UIControl/Contents/Post.ascx");
                    else if(Request["cateid"] != null && Request["postid"] != null)
                        c = Page.LoadControl("UIControl/Contents/Post.ascx");
                    else if(Request["cateid"] != null && Request["postid"] != null && Request["action"].ToString().Equals("reply"))
                        c = Page.LoadControl("UIControl/Contents/Reply.ascx");
                    else if(Request["cateid"] != null && Request["action"].ToString().Equals("add"))
                        c = Page.LoadControl("UIControl/Contents/PostAdd.ascx");
                }
                //Feedback module
                if (module.Equals("feedback"))
                {
                    c = Page.LoadControl("UIControl/Contents/Feedback.ascx");
                }
                //AboutMed module
                if (module.Equals("aboutme"))
                {
                    c = Page.LoadControl("UIControl/Contents/AboutMe.ascx");
                }
            }
            else
            {
                //Default to all categories
                c = Page.LoadControl("UIControl/Contents/Home.ascx");
            }


            mainContent.Controls.Add(c);
        }
        protected override void OnPreLoad(EventArgs e)
        {
            base.OnPreLoad(e);
            Page.Title = "Doctor Web Forum";
        }
    }
}
